//
//  LZGrabCouponAndFightGroupsDetialModel.m
//  laziz_Consumer
//
//  Created by xbnzd on 16/11/16.
//  Copyright © 2016年 XBN. All rights reserved.
//

#import "LZGrabCouponAndFightGroupsDetialModel.h"
#import "MJProperty.h"
#import "LZDateFormatterManager.h"

@implementation LZGrabCouponAndFightGroupsDetialModel

- (id)mj_newValueFromOldValue:(id)oldValue property:(MJProperty *)property
{
    if ([oldValue isKindOfClass:[NSNull class]]){
        return @"";
        }
    
    if ([property.name isEqualToString:@"couponsExceptTime"] || [property.name isEqualToString:@"grouponExceptTime"]) {
        if (oldValue != nil) {
            NSString *ss = (NSString *)oldValue;
            if (ss.length == 0) {
                return @"none";
            }
        }
    }
    
    if ([property.name isEqualToString:@"couponsStartDaytime"] || [property.name isEqualToString:@"couponsEndDaytime"] || [property.name isEqualToString:@"grouponStartDaytime"] || [property.name isEqualToString:@"grouponEndDaytime"]) {
        if (oldValue != nil) {
            NSString *ss = (NSString *)oldValue;
            if (ss.length > 0) {
                return [[LZDateFormatterManager shareInstance] stringFromStringNormalHaveLineHHmm:ss];
            }
        }
    }
    
    return oldValue;
}

+ (NSDictionary *)mj_replacedKeyFromPropertyName{
    /* 返回的字典，key为模型属性名，value为转化的字典的多级key */
    return @{
             @"videoId" : @"id"
            };
}

- (NSInteger)couponsResidueCount
{
    NSInteger residue = _couponsTotalCount - _couponsGetCount;
    
    return residue;
}

// 获取团购类型每天的有效期
- (NSString*)getGroupEverydayValid {
    NSString *everyDayValid = nil;
    if ([LZLanguageManager shareInstance].getLanguageType == LanguageType_Ar) {
        everyDayValid = [NSString stringWithFormat:@"%@ - %@",self.grouponEndDaytime,self.grouponStartDaytime];
    }
    else {
        everyDayValid = [NSString stringWithFormat:@"%@ - %@",self.grouponStartDaytime,self.grouponEndDaytime];
    }
    return everyDayValid;
}

// 获取优惠券类型每天的有效期
- (NSString*)getCouponEverydayValid {
    NSString *everyDayValid = nil;
    if ([LZLanguageManager shareInstance].getLanguageType == LanguageType_Ar) {
        everyDayValid = [NSString stringWithFormat:@"%@ - %@",self.couponsEndDaytime,self.couponsStartDaytime];
    }
    else {
        everyDayValid = [NSString stringWithFormat:@"%@ - %@",self.couponsStartDaytime,self.couponsEndDaytime];
    }
    return everyDayValid;
    
}

@end
